<template>
  <div class="search-shell theme-bg-color">
    <div class="search-main"
         :style="`height:${height}`">
      <div class="search-shell-left">
        <div class="search-form">
          <slot name='form'></slot>
        </div>
        <div class="search-submit"
             v-show="showSearchBtn">
          <el-button type="primary"
                     @click="search">{{ $t('query') }}</el-button>
        </div>
      </div>
      <div v-if="operationButton"
           class="search-shell-right">
        <slot name='btns'></slot>
      </div>
    </div>
    <i @click="handleExtend"
       v-show="downIcon"
       :class="[isHandleDown ? 'el-icon-arrow-up':'el-icon-arrow-down','icon-arrow theme-bg-color']"></i>
  </div>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import minFormValidate from '@/mixins/form-validate'
export default {
  mixins: [minFormValidate, mixinViewModule],
  props: {
    operationButton: {
      type: Boolean,
      default: true
    },
    showSearchBtn: {
      type: Boolean,
      default: true
    },
    downIcon: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      name: '',
      height: '75px',
      isHandleDown: false
    }
  },
  methods: {
    search () {
      this.$emit('sumbit')
    },
    handleExtend () {
      if (this.isHandleDown) {
        this.isHandleDown = false
        this.height = '75px'
      } else {
        this.isHandleDown = true
        this.height = '100%'
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.search-shell {
  width: 100%;
  align-items: center;
  position: relative;
  .search-main {
    // transition: all 0.5s;
    width: 100%;
    display: flex;
    overflow: hidden;
    .search-shell-left {
      flex: 1.5;
      height: 100%;
      display: flex;
    }
    .search-shell-right {
      flex: 1;
      height: 100%;
      text-align: right;
    }
  }
  .icon-arrow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    // background-color: white;
  }
}
</style>
